<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3941：[Usaco2015 Feb]Fencing the Herd</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2015 Feb]Fencing the Herd</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2015 Feb]Fencing the Herd</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Usaco2015 Feb]Fencing the Herd                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>Farmer John needs your help deciding where to build a fence in the shape of a straight line to help&nbsp;</div>
<div>restrict the movement of his cows. He has considered several possible fence locations and needs your&nbsp;</div>
<div>help to determine which of these are usable, where a fence is considered usable if all of the cows&nbsp;</div>
<div>are on the same side of the fence. A fence is not usable if there is a cow that lies directly on it.&nbsp;</div>
<div>FJ will be asking you a number of queries regarding possible fence locations; a query should be&nbsp;</div>
<div>answered &quot;YES&quot; if it corresponds to a usable fence location, &quot;NO&quot; otherwise.</div>
<div>Additionally, FJ may occasionally bring new cows into the herd. When a new cow joins the herd, all&nbsp;</div>
<div>fence queries from that point onward will require her to be on the same side of a fence as the rest&nbsp;</div>
<div>of the herd for the fence to be usable.FJ需要你帮助他决定在哪里建造形状是一条无限长的直线的栅栏来限制</div>
<div>他的牛的活动。他选出了几个可能的建造栅栏的位置，你需要帮助他判断哪些栅栏是有用的。一个栅栏是有用的当且</div>
<div>仅当所有奶牛都在栅栏的同一侧(如果有牛群在栅栏所在的直线上，那么栅栏是没用的)，FJ将会问你一些问题，如果</div>
<div>这个栅栏是有用的，需要输出&ldquo;YES&rdquo;，反之输出&ldquo;NO&rdquo;。 另外，FJ也可能会带来一些新的奶牛加入这个牛群。一头牛</div>
<div>加入之后，以后的所有询问中，这头牛也需要与其它的牛在栅栏的同一侧。&nbsp;</div>
<p style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></p>
<p></p></p><hr/><h3>输入格式</h3><p><div>
<div>The first line of input contains N (1 &lt;= N &lt;= 100,000) and Q (1 &lt;= Q &lt;= 100,000) separated by a space.&nbsp;</div>
<div>These give the number of cows initially in the herd and the number of queries, respectively.</div>
<div>The following N lines describe the initial state of the herd. Each line will contain two space separated&nbsp;</div>
<div>integers x and y giving the position of a cow.</div>
<div>The remaining Q lines contain queries either adding a new cow to the herd or testing a fence for usability.&nbsp;</div>
<div>A line of the form &quot;1 x y&quot; means that a new cow has been added to the herd at position (x, y). A line of&nbsp;</div>
<div>the form &quot;2 A B C&quot; indicates that FJ would like to test a fence described by the line Ax + By = C.</div>
<div>All cow positions will be unique over the whole data set and will satisfy (-10^9 &lt;= x, y &lt;= 10^9).&nbsp;</div>
<div>Additionally the fence queries will satisfy -10^9 &lt;= A, B &lt;= 10^9 and -10^18 &lt;= C &lt;= 10^18. No fence&nbsp;</div>
<div>query will have A = B = 0.</div>
<div>第一行包含两个用空格隔开的整数N和Q代表最开始奶牛的数目和FJ的提问的个数。&nbsp;</div>
<div>接下来的N行每行包含两个整数x和y，代表每只奶牛的坐标&nbsp;</div>
<div>最后的Q行，每行代表一个提问，形如&ldquo;1 x y&rdquo;的提问代表FJ在坐标为(x,y)的位置放置了一头新的奶牛。形如&quot;2 A B C&quot;的</div>
<div>提问代表FJ向你询问位于直线Ax+By+C上的栅栏是否是有用的。</div>
</div>
<div>
<p style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></p>
</div>
<p></p></p><hr/><h3>输出格式</h3><p><h4>
<div>
<div>
<div style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;">
<div></div>
</div>
<div><span style="font-size: 14px; font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif;">For each fence query, output &quot;YES&quot; if the fence is usable. Otherwise output &quot;NO&quot;.</span></div>
<div><font face="Raleway, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="font-size: 14px;">对于每个形如&ldquo;2 A B C&rdquo;的提问，输出一行。&nbsp;</span></font></div>
<div><font face="Raleway, Helvetica Neue, Helvetica, Arial, sans-serif"><span style="font-size: 14px;">如果栅栏是有用的，输出&quot;YES&quot;，否则输出&quot;NO&quot;(不包含引号)。</span></font></div>
<div style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;">
<div></div>
</div>
<div style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></div>
</div>
<div style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></div>
</div>
<div style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></div>
</h4>
<p style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></p>
<p></p></p><hr/><h3>样例输入</h3><pre>3 4
0 0
0 1
1 0
2 2 2 3
1 1 1
2 2 2 3
2 0 1 1</pre><hr/><h3>样例输出</h3><pre>YES
NO
NO</pre><hr/><h3>提示</h3><p><p>&nbsp;数据范围：&nbsp;</p>
<div>1&lt;=N&lt;=100000 , 1&lt;=Q&lt;=100000&nbsp;</div>
<div>-109&lt;=x,y&lt;=109&nbsp;</div>
<div>-109&lt;=A,B&lt;=109&nbsp;</div>
<div>-1018&lt;=C&lt;=1018&nbsp;</div>
<div>输入数据保证所有奶牛的坐标都是互不相同的，而且不会出现A=B=0的询问。&nbsp;</div>
<div>样例解释:&nbsp;</div>
<div>最开始的三头牛都在2x+2y=3这条直线同侧，但是奶牛(1,1)加入后，与其它三头牛不在同一侧，所有第二个栅栏是没用的。因为奶牛(0,1)和奶牛(1,1)在直线y=1上，所以第三个栅栏是没用的&nbsp;</div>
<div></div></p><hr/><h3>题目来源</h3><p>Gold</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3941" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3941" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>